import { Injectable } from '@nestjs/common';
import { UserNameEntity } from '../entities/username.entity'
import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";

@Injectable()
export class LoginService {

      // 使用InjectRepository装饰器并引入Repository这样就可以使用typeorm的操作了
  constructor(
    @InjectRepository(UserNameEntity)
    private readonly userRepository: Repository<UserNameEntity>,
  ) { }

    // 返回查出来的username
    async findAll(): Promise<UserNameEntity[]> {
        return await this.userRepository.query('select * from userinfo');
      }

  
}
